package top.frsf.pattern.b_structural.b_proxy.b_jdk;

import top.frsf.pattern.b_structural.b_proxy.a_statics.SubjectProxy;
import top.frsf.pattern.b_structural.b_proxy.pojo.RealSubject;
import top.frsf.pattern.b_structural.b_proxy.pojo.Subject;

import java.lang.reflect.Proxy;

/**
 * JDK动态代理
 * 1. Proxy ( InvokeHandler (target) )
 * 2. Proxy -- Reflect Gen -- Static Method
 * 3. Proxy --> some method --> InvokeHandle.invoke(proxy, method, args) --> method.invoke(target, args)
 *
 * @author He Kuntao
 * @since 2024/9/18 17:12
 */
public class Test {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles","true");

        Subject proxy = (Subject) DynamicProxyFactory.getProxy(RealSubject.class);
        proxy.request();
    }
}
